package com.fzu.mmdbproxyframework.cluster.passcloud;

import java.util.HashMap;

import net.sf.json.JSONObject;

public class QueryAsyncJob {
	int jobStatus = 0;
	static JSONObject json;

	public static JSONObject sendAsynRequest(String jobId) {
		HashMap<String, String> params = new HashMap<String, String>();
		params.put("jobid", jobId);
		JSONObject json;
		while (true) {
			json = JSONObject.fromObject(
					SendRequest.sendRequest(InternetwareCmd.QueryAsyncJobCmd,
							params)).getJSONObject(
					"queryasyncjobresultresponse");
			switch (json.getInt("jobstatus")) {
			case 0:
				break;
			case 1:
			case 2:
				return json;
			}
			if (json.getInt("jobstatus") != 0) {
				break;
			}
			try {
				Thread.sleep(3000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		return json;
	}
}
